<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>11-伪元素选择器使用场景-仿土豆</title>
  <style>
    .tudou {
      /* 子绝父相 */
      position: relative;
      width: 442px;
      height: 320px;
      background: pink;
      margin: 30px auto;
    }

    .tudou img {
      /* 图片保持与父亲一样大 */
      width: 100%;
      height: 100%;
    }

    /* 遮层 */
    .tudou::before {
      content: '';
      /* 隐藏遮罩层 不占位置 */
      display: none;
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      /* 垂直水平居中 */
      background: rgba(0, 0, 0, 0.3) url(images/arr.png) no-repeat center;
    }

    /* 鼠标经过了土豆这个盒子 就让before遮罩层显示出来 */
    .tudou:hover::before {
      display: block;
    }
  </style>
</head>

<body>

  <div class="tudou">
    <img src="images/tudou.jpg" alt="">
  </div>

</body>

</html>